<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="./vue.js"></script>
  <script src="./vue-router.js"></script>
</head>

<body>
  <div id="app">
    <router-link to="/user/100/admin">登录</router-link>
    <router-view></router-view>
  </div>



  <script>
    // 定义组件
    let user = {
      template: `<h1>id:{{$route.params.id}} + name:{{$route.params.name}}</h1>`,
      created() {
        // 单条路由
        console.log(this.$route)
      }
    }

    // 定义路由规则对象
    let router = new VueRouter({
      routes: [{
        path: "/user/:id/:name",
        component: user
      }]
    })

    var vm = new Vue({
      el: "#app",
      router
    })
  </script>
</body>

</html>